"use client"; import { useState } from "react"; export function UploadForm({ paperId, csrf, nextNo }: { paperId: string; csrf: string; nextNo: number }) { const [msg, setMsg] = useState(null); const [busy, setBusy] = useState(false); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); setBusy(true); setMsg(null); const fd = new FormData(e.currentTarget); try { const r = await fetch("/api/admin/upload", { method: "POST", body: fd, headers: { "x-csrf-token": csrf } }); const j = await r.json(); if (!r.ok) throw new Error(j.error ?? r.statusText); setMsg(`Uploaded ${j.label} (sha256 ${String(j.sha256).slice(0, 12)}…). Processing queued.`); setTimeout(() => location.reload(), 1200); } catch (err) { setMsg("Error: " + (err as Error).message); } finally { setBusy(false); } }; return (
{msg &&

{msg}

}
); }